package com.ynwt.repository;

import com.ynwt.domain.UserEvent;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

/**
 * Created by huangying on 2017/5/4.
 */
@Repository
public interface UserEventDao extends PagingAndSortingRepository<UserEvent, Long> {

    int countByUserOpenidAndEventKeyInAndDateGreaterThan(String openid, List keys, Date date);

    int countByUserOpenidAndEventKeyIn(String openid, List keys);

    int countByUserOpenidAndEventKey(String openid, String key);

    Page<UserEvent> findByUserOpenidAndEventKeyIn(String openid, List keys, Pageable pageable);

    Page<UserEvent> findByUserOpenidAndEventKeyStartingWith(String openid, String keyStartStr, Pageable pageable);

    int countByUserOpenidAndEventKeyStartingWith(String openid, String keyStartStr);

    int countByUserOpenidAndDateGreaterThanAndEventKeyStartingWith(String openid, Date date, String keyStartStr);

    Page<UserEvent> findByUserOpenidAndDateGreaterThanAndEventKeyStartingWith(String openid, Date date, String keyStartStr, Pageable pageable);

    List<UserEvent> findByUserOpenidAndDateGreaterThanAndEventKeyStartingWith(String openid, Date date, String keyStartStr);

    Page<UserEvent> findByDateGreaterThanAndEventKeyStartingWith(Date date, String keyStartStr, Pageable pageable);

}
